<template>
    <div>
      <el-row align="middle" class="mytop" v-if="gatherInfo.length>0">
        <el-col :span="4">
          <el-input v-model="trackingNumber" placeholder="请输入入库单号">
            <el-button slot="append" @click="search" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table
        v-loading="loading"
        element-loading-spinner="el-icon-loading"
        :data="gatherInfo" style="width: 100%">
        <el-table-column property="trackingNumber" label="入库单号" width="120"></el-table-column>
        <el-table-column label="入库理由" width="120">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.gatherType=='0'">采购入库</el-tag>
            <el-tag type="success" v-if="scope.row.gatherType=='1'">退货入库</el-tag>
          </template>
        </el-table-column>
        <el-table-column property="gtime" label="入库时间"></el-table-column>
        <el-table-column property="isCheck" label="审核状态">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.isCheck==0">等待审核</el-tag>
            <el-tag type="success" v-if="scope.row.isCheck==1">通过审核</el-tag>
            <el-tag type="success" v-if="scope.row.isCheck==2">拒绝通过</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot="header" slot-scope="scope">
            <el-button icon="el-icon-refresh-right" circle @click="search"></el-button>
          </template>
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click="gatherinfoview(scope.row)"
            >查看详情
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <div>
        <!-- 分页 -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageno"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
      <div>
        <component ref="gatherinfoview" is="gatherinfo_view_details"></component>
      </div>
    </div>
</template>

<script>
  import gatherinfo_view_details from "./gatherinfo_view_details";
    export default {
        name: "storageQuery",
        data(){
          return{
            gatherInfo:[],
            loading: true,
            pageno: 1,
            pagesize: 5,
            total: 1,
            trackingNumber:""
          }
        },
        methods:{
          getData(){
            var obj={
              pageno:this.pageno,
              pagesize:this.pagesize,
              trackingNumber:this.trackingNumber

            }
            this.$axios.get("gatherInfo/queryAllGatherInfo.action",{params:obj}).then(res=>{
              this.gatherInfo=res.data.records;
              this.total=res.data.total;
              console.log(this.gatherInfo)
              this.loading=false
            }).catch(error=>{this.$message.error(error)})
          },
          handleSizeChange(val) {
            //每页范围
            this.pagesize = val;
            this.getData();
          },
          handleCurrentChange(val) {
            //当前页
            this.pageno = val;
            this.getData();
          },
          search() {
            this.getData();
          },
          gatherinfoview(row){
            this.$refs.gatherinfoview.dialogTableVisible=true;
            this.$refs.gatherinfoview.gatherdetails.gatherId=row.id
            this.$refs.gatherinfoview.getgatherdetaildata()
          }
        },
        created() {
          this.getData()
        },
      components:{
        gatherinfo_view_details
      }
    }
</script>

<style scoped>

</style>
